import axios from 'axios';

const manageApiClient = axios.create({
    baseURL: 'manage_api',
    timeout: 1000,
    headers: { 'Content-Type': 'application/json' },
});

// 添加响应拦截器
manageApiClient.interceptors.response.use(response => {
    // 对响应数据做点什么
    if (response.data.success === true) {
        return response.data;
    }
    else {
        return Promise.reject(response.data.message);
    }
}, error => {
    // 对响应错误做点什么
    return Promise.reject(error);
});

export default {
    getTempHumidByDeviceId(id) {
        return manageApiClient.get(`tempHumid/getByDeviceId/${id}`);
    },
    getAllTempHumid(){
        return manageApiClient.get(`tempHumid/getAll`);
    }
};